package org.skycloud.mybatis.utils;

public final class StringBuilderUtils {

	private static final ThreadLocal<StringBuilder> THREAD_LOCAL_STRING_BUILDER = new ThreadLocal<StringBuilder>() {

		@Override
		protected StringBuilder initialValue() {
			return new StringBuilder();
		}
	};

	private StringBuilderUtils() {
	}

	public static StringBuilder getThreadLocalStringBuilder() {
		return THREAD_LOCAL_STRING_BUILDER.get();
	}

	public static StringBuilder getThreadLocalStringBuilder(int newLength) {
		StringBuilder stringBuilder = THREAD_LOCAL_STRING_BUILDER.get();
		stringBuilder.setLength(0);

		return stringBuilder;
	}
}
